<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <link rel="stylesheet" th:href='@{/plugin/css/report.css}' href="../static/css/report.css"/>
  </head>
  <body>
    <div class="container-fluid" role="main">

      <div class="panel panel-default">
        <div class="panel-heading">
          <h3 class="panel-title">Security Rules:
            <span th:text="${#numbers.formatInteger(securityRules.getTotal(),0,'DEFAULT')}"></span>
          </h3>
        </div>
        <div class="panel-body">
          <table class="fixed"
                 th:fragment="table"
                 th:classappend="${includeRuleDocumentation != null and includeRuleDocumentation and customPropertyHelper != null} ? with-rule-doc">
            <thead>
            <tr>
              <th>Rule Summary</th>
              <th th:if="${(showHitCount != null and showHitCount) or (showLastUsed != null and showLastUsed)}">Usage</th>
              <th th:if="${showComplexity}">Logical Rules</th>
              <th th:if="${showExpiration}">Expiration</th>
              <th>Source / User</th>
              <th>Destination</th>
              <th>Application / Service</th>
              <th>Action</th>
              <th>Logging</th>
              <th>Comments</th>
            </tr>
            </thead>
            <tbody th:with="df=#{ShortDateTimeFormat}">
              <!--/*/ <th:block th:each="rule : ${securityRules}"> /*/-->
              <tr th:class="${rowActionClass}">
                <!-- summary -->
                <td>
                  <div th:if="${rowActionClass}" th:class="${rowActionIcon.forRow(rowActionClass)}"></div>
                  <div th:class="${rowActionClass} ? right-cell">
                    <div th:if="${rule.getPolicy() != null}">
                      <span class="rule-property-heading">Policy:</span>
                      <span th:text="${rule.getPolicy().getName()}">Policy Name</span>
                    </div>
                    <div th:if="${rule.getRuleNumber() != null or rule.getRuleNumberStr() != null}">
                      <span class="rule-property-heading">
                        Number:
                      </span>
                      <span th:if="${rule.getRuleNumberStr() != null}" th:text="${rule.getRuleNumberStr()}">1.1</span>
                      <span th:if="${rule.getRuleNumberStr() == null}" th:text="${#numbers.formatInteger(rule.getRuleNumber(),0,'DEFAULT')}">1</span>
                    </div>
                    <div th:if="${rule.getRuleName() != null}">
                      <span class="rule-property-heading">
                        Name:
                      </span>
                      <span th:text="${rule.getRuleName()}">Inbound FTP Access Rule</span>
                    </div>
                    <div>
                      <span th:if="${rule.getDisabled()}">
                        <span class="label label-warning">Disabled</span>
                      </span>
                    </div>
                  </div>
                </td>
                <!-- usage: hit count / last used -->
                <td th:if="${(showHitCount != null and showHitCount) or (showLastUsed != null and showLastUsed)}">
                  <div th:if="${showHitCount}">
                    <div class="rule-property-heading">Hit Count</div>
                    <div th:if="${rule.getHitCount() != null}" th:text="${#numbers.formatInteger(rule.getHitCount(),0,'DEFAULT')}">999</div>
                    <div th:if="${rule.getHitCount() == null}">0</div>
                  </div>

                  <hr th:if="${(showHitCount != null and showHitCount) and (showLastUsed != null and showLastUsed)}" class="hr--tight"/>
                  <div th:if="${showLastUsed}" class="text-nowrap">
                    <div class="rule-property-heading">Last Used</div>
                    <div th:switch="${rule.getLastUsed() == null}">
                      <div th:case="${true}">Never</div>
                      <div th:case="${false}" th:text="${#temporals.format(rule.getLastUsed(),df)}">January 12, 2015 9:19:00 AM CST</div>
                    </div>
                  </div>
                </td>
                <!-- complexity -->
                <td th:if="${showComplexity}">
                  <span th:if="${rule.getComplexity() != null}" th:text="${#numbers.formatInteger(rule.getComplexity(),0,'DEFAULT')}">5</span>
                </td>
                <!-- expiration -->
                <td th:if="${showExpiration}">
                  <span th:if="${rule.getExpirationDate() != null}"
                        th:text="${#temporals.format(rule.getExpirationDate(),df)}" class="text-nowrap">January 12, 2015 9:19:00 AM CST</span>
                  </span>
                </td>
                <!-- Source/User -->
                <td>
                  <div th:if="${showObjectCount == true}">
                    <span class="rule-property-heading" th:text="|#{Sources}: ${objectCountMap.get(rule.getMatchId()).getSourceCount()} / #{Users}: ${objectCountMap.get(rule.getMatchId()).getUserCount()}|"></span>
                    <hr class="hr--tight"/>
                  </div>
                  <div th:if="${rule.getSrcContext() != null and rule.getSrcContext().getZones() != null}">
                    <div class="rule-property-heading">Source Zone</div>
                    <div th:each="item : ${rule.getSrcContext().getZones()}">
                      <div th:replace="Siql.html::objectDetail(makeLink=${linkTopLevelObject}, makeAnchor=${false})"></div>
                    </div>
                  </div>
                  <div th:if="${rule.getSources() != null and rule.getSources().size() > 0}">
                    <hr th:if="${rule.getSrcContext() != null and rule.getSrcContext().getZones() != null}" class="hr--tight"/>
                    <div class="rule-property-heading" th:text="#{Source}">Source</div>
                    <div th:replace="Siql.html::negatedTreatment(isNegated = ${rule.getSrcNegated()}, objectList = ${rule.getSources()}, makeAnchor = ${false})"></div>
                  </div>
                  <div th:if="${rule.getUsers() != null and rule.getUsers().size() > 0}">
                    <hr
                        th:if="${(rule.getSrcContext() != null and rule.getSrcContext().getZones() != null) or
                                 (rule.getSources() != null and rule.getSources().size() > 0) }"
                        class="hr--tight"/>
                    <div>User</div>
                    <div th:replace="Siql.html::negatedTreatment(isNegated = ${rule.getUserNegated()}, objectList = ${rule.getUsers()}, makeAnchor = ${false})"></div>
                  </div>
                </td>
                <!-- Destination -->
                <td>
                  <div th:if="${showObjectCount == true}">
                    <span class="rule-property-heading" th:text="|#{Destinations}: ${objectCountMap.get(rule.getMatchId()).getDestinationCount()}|"></span>
                    <hr class="hr--tight"/>
                  </div>
                  <th:block th:if="${rule.getDstContext() != null and rule.getDstContext().getZones() != null}">
                    <div class="rule-property-heading">Destination Zone</div>
                    <div th:each="item : ${rule.getDstContext().getZones()}">
                      <div th:replace="Siql.html::objectDetail(makeLink=${linkTopLevelObject}, makeAnchor=${false})"></div>
                    </div>
                  </th:block>
                  <div th:if="${rule.getDestinations() != null and rule.getDestinations().size() > 0}">
                    <hr th:if="${rule.getDstContext() != null and rule.getDstContext().getZones() != null}" class="hr--tight"/>
                    <div class="rule-property-heading">Destination</div>
                    <div th:replace="Siql.html::negatedTreatment(isNegated = ${rule.getDstNegated()}, objectList = ${rule.getDestinations()}, makeAnchor = ${false})"></div>
                  </div>
                </td>
                <!-- Application / Service -->
                <td>
                  <div th:if="${showObjectCount == true}">
                    <span class="rule-property-heading" th:text="|#{Applications}: ${objectCountMap.get(rule.getMatchId()).getAppCount()} / #{Services}: ${objectCountMap.get(rule.getMatchId()).getServiceCount()}|"></span>
                    <hr class="hr--tight"/>
                  </div>
                  <div th:if="${rule.getApps() != null and rule.getApps().size() > 0}">
                    <div class="rule-property-heading">Application</div>
                    <div th:replace="Siql.html::negatedTreatment(isNegated = ${rule.getAppNegated()}, objectList = ${rule.getApps()}, makeAnchor = ${false})"></div>
                  </div>
                  <div th:if="${rule.getServices() != null and rule.getServices().size() > 0}">
                    <hr th:if="${rule.getApps() != null and rule.getApps().size() > 0}" class="hr--tight"/>
                    <div class="rule-property-heading">Service</div>
                    <div th:replace="Siql.html::negatedTreatment(isNegated = ${rule.getSvcNegated()}, objectList = ${rule.getServices()}, makeAnchor = ${false})"></div>

                  </div>
                </td>
                <!-- action -->
                <td class="text-nowrap">
                  <span th:class="${actionIcon.forRule(rule)}"></span>
                  <span th:text="${#messages.msg(rule.getRuleAction())}">Accept</span>
                </td>
                <!-- logging -->
                <td>
                  <span th:if="${rule.getLog()}" th:text="#{Enabled}">Enabled</span>
                  <span th:if="${rule.getLog() != true}" th:text="#{Disabled}">Disabled</span>
                </td>
                <!-- comment -->
                <td th:text="${rule.getCommentText()}" style="width: 20%" class="text-linebreaks">This is a not really long comment.</td>
              </tr>
              <!--/*/ <th:block th:if="${includeRuleDocumentation} and ${customPropertyHelper}" th:with="props=${customPropertyHelper.getProperties(rule)}"> /*/-->
              <tr>
                <td colspan="7" class="rule-doc">
                  <!--/*/ <th:block th:each="prop, iterator : ${props}"> /*/-->
                  <div>
                    <small>
                      <strong th:text="${prop.name}">Name</strong>:
                      <span th:text="${prop.value}">Value</span>
                    </small>
                  </div>
                  <!--/*/ </th:block> /*/-->
                </td>
              </tr>
              <!--/*/ </th:block> /*/-->
              <!--/*/ </th:block> /*/-->
            </tbody>
          </table>

          <ul th:fragment="networks (networks)" class="list-unstyled">
            <div th:replace="Siql.html::objectList(objectList = ${networks}, truncate=${false}, makeAnchor=${true}, linkTopLevelObject=${false})"></div>
          </ul>

          <ul th:fragment="services (services)" class="list-unstyled">
            <div th:replace="Siql.html::objectList(objectList = ${services}, truncate=${false}, makeAnchor=${true}, linkTopLevelObject=${false})"></div>
          </ul>

          <ul th:fragment="apps (apps)" class="list-unstyled">
            <div th:replace="Siql.html::objectList(objectList = ${apps}, truncate=${false}, makeAnchor=${true}, linkTopLevelObject=${false})"></div>
          </ul>

          <ul th:fragment="users (users)" class="list-unstyled">
            <div th:replace="Siql.html::objectList(objectList = ${users}, truncate=${false}, makeAnchor=${true}, linkTopLevelObject=${false})"></div>
          </ul>

          <ul th:fragment="zones (zones)" class="list-unstyled">
            <li th:each="item : ${zones}">
              <span th:class="${icons.forObject(item)}" class="icon-zone_object"></span>
              <span th:id="${item.getMatchId()}" th:text="${item.getName()}">Trust</span>
              <ul th:if="${report.isIncludeGroupMembers() and item.getInterfaces().size() > 0}" class="list-group--members">
                <li th:each="item : ${item.getInterfaces()}">
                  <span th:text="${item.getName()}">ethernet1/1</span>
                  <span th:if="${item.getInactive()}">(inactive)</span>
                  <span th:if="${item.getPrimaryAddress() != null}" th:text="|(${item.getPrimaryAddress().getAddress()})|">(192.168.20.0/24)</span>
                </li>
              </ul>
              <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                <li th:each="item : ${item.getMembers()}">
                  <span th:class="${icons.forObject(item)}" class="icon-zone_object"></span>
                  <span th:text="${item.getName()}">Trust</span>
                  <ul th:if="${report.isIncludeGroupMembers() and item.getInterfaces().size() > 0}" class="list-group--members">
                    <li th:each="item : ${item.getInterfaces()}">
                      <span th:text="${item.getName()}">ethernet1/1</span>
                      <span th:if="${item.getInactive()}">(inactive)</span>
                      <span th:if="${item.getPrimaryAddress() != null}" th:text="|(${item.getPrimaryAddress().getAddress()})|">(192.168.20.0/24)</span>
                    </li>
                  </ul>
                  <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                    <li th:each="item : ${item.getMembers()}">
                      <span th:class="${icons.forObject(item)}" class="icon-zone_object"></span>
                      <span th:text="${item.getName()}">Trust</span>
                      <ul th:if="${report.isIncludeGroupMembers() and item.getInterfaces().size() > 0}" class="list-group--members">
                        <li th:each="item : ${item.getInterfaces()}">
                          <span th:text="${item.getName()}">ethernet1/1</span>
                          <span th:if="${item.getInactive()}">(inactive)</span>
                          <span th:if="${item.getPrimaryAddress() != null}" th:text="|(${item.getPrimaryAddress().getAddress()})|">(192.168.20.0/24)</span>
                        </li>
                      </ul>
                      <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                        <li th:each="item : ${item.getMembers()}">
                          <span th:class="${icons.forObject(item)}" class="icon-zone_object"></span>
                          <span th:text="${item.getName()}">Trust</span>
                          <ul th:if="${report.isIncludeGroupMembers() and item.getInterfaces().size() > 0}" class="list-group--members">
                            <li th:each="item : ${item.getInterfaces()}">
                              <span th:text="${item.getName()}">ethernet1/1</span>
                              <span th:if="${item.getInactive()}">(inactive)</span>
                              <span th:if="${item.getPrimaryAddress() != null}" th:text="|(${item.getPrimaryAddress().getAddress()})|">(192.168.20.0/24)</span>
                            </li>
                          </ul>
                          <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                            <span>Members omitted for brevity...</span>
                          </ul>
                        </li>
                      </ul>
                    </li>
                  </ul>
                </li>
              </ul>
            </li>
          </ul>
        </div>
      </div>

      <!-- Negated treatment -->
      <div th:fragment="negatedTreatment">
        <div th:if="${isNegated}">
          <div class="fm-tree-wrapper--negated">
            <div class="fm-tree-wrapper__negated-header">
              <span class="icon icon--minus-circle-closed remove-red"></span>
              <span th:text="#{Negated}"></span>
            </div>
            <div th:replace="Siql.html::objectList(objectList = ${objectList}, makeAnchor = ${makeAnchor})"></div>
          </div>
        </div>
        <div th:if="${!isNegated}">
          <div th:replace="Siql.html::objectList(objectList = ${objectList}, makeAnchor = ${makeAnchor})"></div>
        </div>
      </div>

      <!--/* Creates list for an object, caller can set 'truncate' to be true if the list should be truncated at the
      siqlObjectDetailsHelper.MAX_LIST_SIZE otherwise the full list (up to four levels deep) will be created */-->
      <div th:fragment="objectList">
        <div th:each="item, iterator : ${objectList}">
          <div
              th:replace="Siql.html::objectDetail(makeLink=${linkTopLevelObject}, makeAnchor=${makeAnchor})"></div>
          <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
            <li th:each="item,iterator2 : ${item.getMembers()}" th:unless="${truncate and iterator2.count gt details.maxListSize}">
              <div th:replace="Siql.html::objectDetail(makeAnchor=${false})"></div>
              <div th:if="${truncate and iterator2.count == details.maxListSize}">
                <span th:replace="Siql.html::maxListSizeMessage(${iterator2.count}, ${iterator2.size})"></span>
              </div>
              <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                <li th:each="item, iterator3 : ${item.getMembers()}" th:unless="${truncate and iterator3.count > details.maxListSize}">
                  <div th:replace="Siql.html::objectDetail(makeAnchor=${false})"></div>
                  <div th:if="${truncate and iterator3.count == details.maxListSize}">
                    <span th:replace="Siql.html::maxListSizeMessage(${iterator3.count}, ${iterator3.size})"></span>
                  </div>
                  <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                    <li th:each="item, iterator4 : ${item.getMembers()}" th:unless="${truncate and iterator4.count > details.maxListSize}">
                      <div th:replace="Siql.html::objectDetail(makeAnchor=${false})"></div>
                      <div th:if="${truncate and iterator4.count == details.maxListSize}">
                        <span th:replace="Siql.html::maxListSizeMessage(${iterator4.count}, ${iterator4.size})"></span>
                      </div>
                      <ul th:if="${report.isIncludeGroupMembers() and item.getMembers().size() > 0}" class="list-group--members">
                        <span>Members omitted for brevity...</span>
                      </ul>
                    </li>
                  </ul>
                </li>
              </ul>
            </li>
          </ul>
        </div>
      </div>

      <div th:fragment="objectDetail">
        <span th:class="${icons.forObject(item)}" class="icon-application_object"></span>
        <a th:if="${(makeLink != null and makeLink) and (linkToName != null and linkToName)}"
           th:href="|#${details.hrefPrefix(item) + item.getName()}|"
           th:text="${item.getName()}">Internal</a>
        <a th:if="${(makeLink != null and makeLink) and (linkToName == null or !linkToName)}" th:href="|#${item.getMatchId()}|"
           th:text="${item.getName()}">Internal</a>
        <span th:unless="${makeLink}" th:attr="id=${makeAnchor} ? ${item.getMatchId()} : null"
              th:text="${item.getName()}">192.168.20.0/24</span>
        <small th:if="${includeObjectDetails and (!report.isIncludeGroupMembers() || item.getMembers().size() == 0)}"
           th:text="${details.forObject(item)}">192.168.20.0/24</small>
        <small th:if="${showObjectHitCount}" class="text-info">
          [<span th:text="${hitCount.forObject(item)}"
                th:classappend="${hitCount.forObject(item)} == 0 ? severity-critical : severity-high">
          </span>]
        </small>
      </div>

      <div th:fragment="maxListSizeMessage(count, total)">
        <span th:if="${total > count}" th:text="|...${total - details.maxListSize} more|">...lots more</span>
      </div>

      <div th:fragment="objectListSpecificDevice">
        <div class="container-fluid">
          <div class="row">
            <div class="col-xs-12">

              <div th:id="networks" th:if="${networks != null and networks.size() > 0}" class="panel panel-default">
                <div class="panel-heading">
                  <div class="pull-right"><a href="#top" th:text="#{Top}">Top</a></div>
                  <h3 class="panel-title">
                    <span th:text="#{NetworkObjects}">Network Objects</span>:
                    <span th:text="${networks.size()}"></span>
                  </h3>
                </div>
                <div class="panel-body">
                  <div class="object-list-bordered">
                    <span th:replace="Siql.html :: networks (networks=${networks})" />
                  </div>
                </div>
              </div>

              <div th:id="applications" th:if="${apps != null and apps.size() > 0}" class="panel panel-default">
                <div class="panel-heading">
                  <div class="pull-right"><a href="#top" th:text="#{Top}">Top</a></div>
                  <h3 class="panel-title">
                    <span th:text="#{ApplicationObjects}">Application Objects</span>:
                    <span th:text="${apps.size()}"></span>
                  </h3>
                </div>
                <div class="panel-body">
                  <div class="object-list-bordered">
                    <span th:replace="Siql.html :: apps (apps=${apps})" />
                  </div>
                </div>
              </div>

              <div th:id="services" th:if="${services != null and services.size() > 0}" class="panel panel-default">
                <div class="panel-heading">
                  <div class="pull-right"><a href="#top" th:text="#{Top}">Top</a></div>
                  <h3 class="panel-title">
                    <span th:text="#{ServiceObjects}">Service Objects</span>:
                    <span th:text="${services.size()}"></span>
                  </h3>
                </div>
                <div class="panel-body">
                  <div class="object-list-bordered">
                    <span th:replace="Siql.html :: services (services=${services})"/>
                  </div>
                </div>
              </div>

              <div th:id="users" th:if="${users != null and users.size() > 0}" class="panel panel-default">
                <div class="panel-heading">
                  <div class="pull-right"><a href="#top" th:text="#{Top}">Top</a></div>
                  <h3 class="panel-title">
                    <span th:text="#{UserObjects}">User Objects</span>:
                    <span th:text="${users.size()}"></span>
                  </h3>
                </div>
                <div class="panel-body">
                  <div class="object-list-bordered">
                    <span th:replace="Siql.html :: users (users=${users})" />
                  </div>
                </div>
              </div>

              <div th:id="zones" th:if="${zones != null and zones.size() > 0}" class="panel panel-default">
                <div class="panel-heading">
                  <div class="pull-right"><a href="#top" th:text="#{Top}">Top</a></div>
                  <h3 class="panel-title">
                    <span th:text="#{Zones}">Zones</span>:
                    <span th:text="${zones.size()}"></span>
                  </h3>
                </div>
                <div class="panel-body">
                  <div class="object-list-bordered">
                    <span th:replace="Siql.html :: zones (zones=${zones})" />
                  </div>
                </div>
              </div>

            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
